/**
 * 
 * @Project le cOeur - Data Virtualization
 * @Date 08.12.2012
 * @Author Aebi Pascal, Kocher Marc
 * @School BFH-TI Biel, Bachelor Thesis
 *
 */

package main.framework.http;

import java.net.URI;

/**
 * This class represents a component defined by the HTTP protocol (RFC-2616).
 */
public class Request extends Message {

	/**
	 * Creates a HTTP request.
	 * The created HTTP request needs to be parsed before the object can be used.
	 * The parsing should be done after all necessary message headers are added.
	 * 
	 * @param requestLine The request line string containing the HTTP method, the requested URI and the HTTP version.
	 */
	public Request(String requestLine) {
		super(new RequestLine(requestLine));
	}
	
	/**
	 * Creates a HTTP request.
	 * 
	 * @param method The HTTP method.
	 * @param requestedURI The requested URI.
	 * @param version The HTTP version.
	 */
	public Request(Method method, URI requestedURI, Version version) {
		super(new RequestLine(method, requestedURI, version));
	}
	
	/**
	 * Returns the method of the HTTP request.
	 * 
	 * @return The HTTP method.
	 */
	public Method getMethod() {
		RequestLine requestLine = (RequestLine) super.startLine;
		return requestLine.getMethod();
	}
	
	/**
	 * Returns the requested URI of the HTTP request.
	 * 
	 * @return The requested URI.
	 */
	public URI getRequestedURI() {
		RequestLine requestLine = (RequestLine) super.startLine;
		return requestLine.getRequestedURI();
	}
	
	/**
	 * Returns the version of the HTTP request.
	 * 
	 * @return The HTTP version.
	 */
	public Version getVersion() {
		RequestLine requestLine = (RequestLine) super.startLine;
		return requestLine.getVersion();
	}

}
